package view.Etudiants.Accueil;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.border.Border;

import view.Fenetre;
import view.Accueil.LogPanel;

@SuppressWarnings("serial")
public class DownPanel extends JPanel implements ActionListener {

	private JButton bUnlog;

	public DownPanel() {

		// Agencement des conteneurs
		GridBagConstraints constraint = new GridBagConstraints();
		this.setLayout(new GridBagLayout());

		// Creation des conteneurs
		bUnlog = new JButton("D\u00E9connexion");
		JPanel pEmpty = new JPanel();		// Ce panneau est utilise pour ajuster la position du bouton de deconnexion

		// Ajout de la transparence
		this.setOpaque(false);
		pEmpty.setOpaque(false);


		// CONTRAINTE DU PANNEAU VIDE

		constraint.gridx = 2;
		constraint.gridy = 0;

		constraint.weightx = 0.9;
		constraint.weighty = 1.0;

		constraint.gridwidth = 9;
		constraint.gridheight = 1;

		constraint.fill = GridBagConstraints.BOTH;

		this.add(pEmpty, constraint);


		// CONTRAINTE DU BOUTON DE DECONNEXION

		constraint.gridx = 1;
		constraint.gridy = 0;

		constraint.weightx = 0.1;
		constraint.weighty = 1.0;

		constraint.gridwidth = 1;
		constraint.gridheight = 1;

		constraint.fill = GridBagConstraints.CENTER;

		this.add(bUnlog, constraint);

		// FIN DES CONTRAINTES


		// Ajout des marges
		Border margin = BorderFactory.createEmptyBorder(5, 5, 10, 5);		// top, left, bottom, right
		this.setBorder(margin);

		// Ajout des ecouteurs aux boutons
		bUnlog.addActionListener(this);

	}

	@Override
	public void actionPerformed(ActionEvent event) {

		LogPanel.wEtudAccueil.erase();
		//Fenetre.control.CompteController().deconnexion();
		Fenetre.fen.refresh();

	}

}
